<?php

/**
 *  установка секретного слова для восстановления пароля
 */
require_once "core/application/controllers/cregistration.php";
require_once "core/application/models/msecret/msecret.php";

class secretWord_Controller extends secretWord_Model {

    private static $_instance = NULL;
    private $_secret          = NULL;

    public static function getInstance() {
        if (is_null(self::$_instance)) {
            $class = __CLASS__;
            self::$_instance = new $class();
        }
        return self::$_instance;
    }

    public function setNewSecretWord() {
        $this->_secret = registration_Controller::getInstance()->generateText();
        try {
            $this->setSecret($_SESSION['name'], $this->_secret);
            $_SESSION['secret'] = $this->_secret;
            $this->echoSuccess("Новое секретное слово установлено");
            $this->alert("Это слово \"" . $this->_secret. "\"");
            $this->redirect(0, "");
        } catch (Exception $e) {
            echo $e->getFile();
            echo $e->getLine();
        }
    }

}

?>
